<template>
  <div>
    <!-- 顶部 -->
    <div class="nav_record_wrap">
      <div class="nav_back" @click="goOff()">返回</div>
      <div class="nav_text">新增/编辑地址</div>
    </div>
    <!-- 编辑或新增地址 -->
    <van-address-edit
      :area-list="areaList"
      show-delete
      show-set-default
      show-search-result
      :search-result="searchResult"
      :area-columns-placeholder="['请选择', '请选择', '请选择']"
      @save="onSave"
      @delete="onDelete"
      @change-detail="onChangeDetail"
    />
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import { showToast } from 'vant';
import { useRouter } from "vue-router";
const router = useRouter();

// 初始化数据
const areaList = ref()
const searchResult = ref([]);
// 自定义事件的回调
// 保存
const onSave = () => showToast('save');
// 删除
const onDelete = () => showToast('delete');

const onChangeDetail = (val) => {
  // if (val) {
  //   searchResult.value = [
  //     {
  //       name: '黄龙万科中心',
  //       address: '杭州市西湖区',
  //     },
  //   ];
  // } else {
  //   searchResult.value = [];
  // }
};

// 返回上一级
const goOff = ()=>{
  router.go(-1)
}

</script>

<style scoped lang="less">
  a{
    color: black;
  }
  *{
    height: 100%;
    background-color: #fafafa;
  }
  .nav_record_wrap{
    display: flex;
    text-align: center;
    height: 44px;
    line-height: 44px;
    justify-content: space-between;
    padding: 0 10px;
    border-bottom: 1px solid #333;
    .nav_back{
      font-size: 18px;
    }
    .nav_text{
      font-size: 18px;
      font-weight: bolder;
      margin-right: 145px;
    }
  }
  
</style>